/* pow.t    PURCHASE ORDER WRITE TRIGGER                              */
/*Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                 */
/*All rights reserved worldwide.  This is an unpublished work.        */
/*V8:ConvertMode=NoConvert */
/*********************************************************************/
/*  Program :pow.t                                                   */
/*  Author  :Ben Holmes                                              */
/*  Date    :12/19/95                                                */
/*  !Description : po_mstr WRITE trigger program                     */
/*          : In order to enhance this trigger to support additional */
/*          : interfaces, add a DO-END block similar to the one      */
/*          : used for the Warehousing Interface to (1) check for the*/
/*          : need to continue processing; (2) move the relevant     */
/*          : fields to an appropriate work area; and (3) call       */
/*          : one or more subprograms to continue processing.        */
/*          : This .t program should remain short, relying on        */
/*          : subprograms to perform most of the work.               */
/*********************************************************************/
/*                             MODIFY LOG                            */
/*********************************************************************/
/*Revision 8.5          Last Modified:  12/19/95 BY: BHolmes *J0FY*  */
/*Revision 8.5          Last Modified:  07/27/96 BY: fwy     *J12B*  */
/*Revision 8.5          Last Modified:  01/07/97 BY: jpm     *J1DM*  */
/*Revision 9.1          Last Modified:  08/13/00 BY: *N0KQ* myb       */
/*                                                                   */
/*                                                                   */
/*********************************************************************/

TRIGGER PROCEDURE FOR WRITE OF PO_MSTR OLD BUFFER OLD_PO_MSTR.

/*J12B  if not can-find(first whl_mstr where whl_mstr.whl_act no-lock) */
/*J12B  then leave. */

    {mfdeclre.i }
    define new shared work-table wf_old_po_mstr like po_mstr.
    define new shared variable w-recid as recid.
    define new shared variable w-site-loc-id like whl_mstr.whl_src_dest_id.

    define variable w-file as character format "x(24)".


    /* Warehousing Interface processing */

    WI:
    do:

    /* If there is no active external warehouse that is flagged to
    receive purchase order export transactions, then do not process */
/*J12B*/    if not can-find(first whl_mstr no-lock
/*J12B*/        where whl_mstr.whl_act and whl_mstr.whl_po_exp)
/*J12B*/    then leave WI.

    /* If this is a blanket purchase order, then do not process */
        if old_po_mstr.po_type = "B"
          or   po_mstr.po_type = "B"
        then leave WI.

    /* If no pertinent fields have been changed, then do not process */
/*J12B*/    if   (old_po_mstr.po_nbr      = po_mstr.po_nbr
/*J12B*/      and old_po_mstr.po_vend     = po_mstr.po_vend
/*J12B*/      and old_po_mstr.po_ord_date = po_mstr.po_ord_date
/*J12B*/      and old_po_mstr.po_due_date = po_mstr.po_due_date
/*J12B*/      and old_po_mstr.po_rmks     = po_mstr.po_rmks
/*J12B*/      and old_po_mstr.po_ship     = po_mstr.po_ship
/*J12B*/      and old_po_mstr.po_fsm_type = po_mstr.po_fsm_type
/*J12B*/      and old_po_mstr.po_sched    = po_mstr.po_sched
/*J12B*/      and old_po_mstr.po_stat     = po_mstr.po_stat
/*J12B*/      and old_po_mstr.po_user1    = po_mstr.po_user1
/*J12B*/      and old_po_mstr.po_user2    = po_mstr.po_user2
/*J12B*/      and old_po_mstr.po_cmtindx  = po_mstr.po_cmtindx)
/*J12B*/    then leave WI.

    /* Move old po_mstr values to work table for subsequent processing */
        assign w-recid = recid(po_mstr).
        create wf_old_po_mstr.
        if recid(wf_old_po_mstr)= -1 then .
        assign
            wf_old_po_mstr.po_nbr       = old_po_mstr.po_nbr
            wf_old_po_mstr.po_vend      = old_po_mstr.po_vend
            wf_old_po_mstr.po_ord_date  = old_po_mstr.po_ord_date
            wf_old_po_mstr.po_due_date  = old_po_mstr.po_due_date
            wf_old_po_mstr.po_rmks      = old_po_mstr.po_rmks
            wf_old_po_mstr.po_ship      = old_po_mstr.po_ship
        wf_old_po_mstr.po_fsm_type  = old_po_mstr.po_fsm_type
            wf_old_po_mstr.po_sched     = old_po_mstr.po_sched
            wf_old_po_mstr.po_stat      = old_po_mstr.po_stat
            wf_old_po_mstr.po_user1     = old_po_mstr.po_user1
            wf_old_po_mstr.po_user2     = old_po_mstr.po_user2
/*J12B*/        wf_old_po_mstr.po_cmtindx   = old_po_mstr.po_cmtindx
        .

    /* Call subprogram to create export transactions for warehouses */
        w-file = "wipow.p".
/*J1DM*/ /* {gprun.i ""wipow.p""} */
/*J1DM*/    {gprunmo.i &module="WI"
                       &program="wipow.p"}

/*J12B*/end. /* WI */
